/**
 * SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
 * SPDX-License-Identifier: Mulan PSL v2
 */
/**
 * Created by zhb on 2020/8/26.
 */

import * as TYPES from '../mutation_types';


let state = {
    newFieldLists: [],
    projectName:'',
    projectId:'',
    dragOperateConfigType: {}, // 增加的操作算子
    isExistDataSet:false,  // 是否存在数据集
    isCsvDataSource:false, // 是否为csv数据源
    featureManagerList:[],
    aiFlowInfo:{}, // 临时保存的aiflow信息
    changeAiFlowInfo:{}, // 训练时修改的aiflow信息
    changeFeatureStepFlag:false // 是否有修改特征探索操作
};

let getters = {
    getNewFieldName (states) {
        return states.newFieldLists;
    },
    projectName (states) {
        return states.projectName;
    },
    projectId (states) {
        return states.projectId;
    },
    dragOperateConfigType (states) {
        return states.dragOperateConfigType;
    },
    isExistDataSet (states) {
        return states.isExistDataSet;
    },
    featureManagerList (states) {
        return states.featureManagerList;
    },
    aiFlowInfo (states) {
        return states.aiFlowInfo;
    },
    changeAiFlowInfo (states) {
        return states.changeAiFlowInfo;
    },
    changeFeatureStepFlag (states) {
        return states.changeFeatureStepFlag;
    }

};

let mutations = {
    [TYPES.PROJECT_NAME] (state, name) {
        state.projectName = name;
    },
    [TYPES.PROJECT_ID] (state, id) {
        state.projectId = id;
    },
    [TYPES.SET_DRAG_OPERATE_CONFIG_TYPE] (state, dragOperateConfigType) {
        state.dragOperateConfigType = dragOperateConfigType;
    },
    [TYPES.IS_EXIST_DATA_SET] (state, isExistDataSet) {
        state.isExistDataSet = isExistDataSet;
    },
    [TYPES.IS_CSV_DATA_SOURCE] (state, isCsvDataSource) {
        state.isCsvDataSource = isCsvDataSource;
    },
    [TYPES.FEATURE_MANAGER_LIST] (state, featureManagerList) {
        state.featureManagerList = featureManagerList;
    },
    [TYPES.AI_FLOW_INFO] (state, info) {
        state.aiFlowInfo = info;
    },
    [TYPES.CHANGE_AI_FLOW_INFO] (state, info) {
        state.changeAiFlowInfo = info;
    },
    [TYPES.CHANGE_FEATURE_STEP_FLAG] (state, flag) {
        state.changeFeatureStepFlag = flag;
    }



};
let actions = {
    setProjectName ({
        commit
    }, payload) {
        commit(TYPES.PROJECT_NAME, payload);
    },
    setProjectId ({
        commit
    }, payload) {
        commit(TYPES.PROJECT_ID, payload);
    },
    setDragOperateConfigType ({
        commit
    }, payload) {
        commit(TYPES.SET_DRAG_OPERATE_CONFIG_TYPE, payload);
    },
    setExistDataSet ({
        commit
    }, payload) {
        commit(TYPES.IS_EXIST_DATA_SET, payload);
    },
    setCsvDataSource ({
        commit
    }, payload) {
        commit(TYPES.IS_CSV_DATA_SOURCE, payload);
    },
    saveFeatureManagerList ({
        commit
    }, payload) {
        commit(TYPES.FEATURE_MANAGER_LIST, payload);
    },
    saveAiFlowInfo ({
        commit
    }, payload) {
        commit(TYPES.AI_FLOW_INFO, payload);
    },
    changeAiFlowInfo ({
        commit
    }, payload) {
        commit(TYPES.CHANGE_AI_FLOW_INFO, payload);
    },
    setChangeFeatureStepFlag ({
        commit
    }, payload) {
        commit(TYPES.CHANGE_FEATURE_STEP_FLAG, payload);
    }
};

export default {
    state,
    getters,
    mutations,
    actions
};
